This section describes the basic building blocks of an assembly language program--these are characters, symbols, labels, and constants.
The following characters are used in assembly language programs
Some of these characters have special meanings, which are described in the section "Expression Syntax" and in the following chapter.
An identifier (also known as a symbol ) can be used for several purposes:
Each identifier consists of a sequence of alphanumeric characters (which may include other printable ASCII characters such as ., _, and $). The first character must not be numeric. Identifiers may be of any length, and all characters are significant. Case of letters is significant--for example, the identifier var is different from the identifier Var.
It is also possible to define a new identifier by enclosing multiple identifiers within a pair of double quotes. For example:
"Object +new:":
.long "Object +new:"
A label is written as an identifier immediately followed by a colon ( :). The label represents the current value of the current location counter; it can be used in assembler instructions as an operand.
You may not use a single identifier to represent two different locations.
Local numeric labels allow compilers and programmers to use names temporarily. A numeric label consists of a digit (between 0 and 9) followed by a colon. These ten local symbol names can be reused any number of times throughout the program. As with alphanumeric labels, a numeric label assigns the current value of the location counter to the symbol.
Although multiple numeric labels with the same digit may be used within the same program, only the next definition and the most recent previous definition of a label can be referenced:
The scope of a label is the distance over which it is visible to (and referenceable by) other parts of the program. Normally, a label that tags a location or data is visible only within the current assembly unit.
The .globl directive (described in Chapter 4) may be used to make a label external. In this case, the symbol is visible to other assembly units at link time.
Four types of constants are available: numeric constants, character constants, string constants, and floating point constants. All constants are interpreted as absolute quantities when they appear in an expression.
A numeric constant is a token that starts with a digit. Numeric constants can be decimal, hexadecimal, or octal. The following restrictions apply:
A single-character constant consists of a single quote ( ' ) followed by any ASCII character. The constant's value is the code for the given character.
A string constant is a sequence of 0 or more ASCII characters surrounded by quotation marks ( "characters" ).
The general lexical form of a floating point number is:
0flt_char [{ +- }] dec ...[ .][ dec ...][ exp_char [{ +- }][ dec ...]]
Item |
Description |
---|---|
a required type specification character (see the following table) |
|
an optional exponent delimiter character (see the following table) |
The type specification character, flt_char , specifies the type and representation of the constructed number; the set of legal type specification characters with the processor architecture, as shown here:
Architecture |
flt_char |
exp_char |
---|---|---|
On the M68000 architecture, 0b can be used to specify an immediate hexadecimal bit pattern. For example:
fmoves #0b7f80001,fp0
moves the signaling Nan into the register fp0 and
fmoves #0x7f80001,fp0
moves the decimal number 2,139,095,041 (0x7f80001 in hexadecimal) into the register fp0.
When floating-point constants are used as arguments to the .single and .double directives, the type specification character isn't actually used in determining the type of the number. For convenience, ror Rcan be used consistently to specify all types of floating-point numbers.
Collectively, all floating point numbers, together with quad and octal scalars, are called Bignums. When as requires a Bignum, a 32-bit scalar quantity may also be used.
Floating point constants are internally represented as flonums, in a machine-independent, precision-independent floating point format (for accurate cross-assembly).
A single period ( .), usually referred to as "dot," is used to represent the current location counter. There is no way to explicitly reference any other location counters besides the current location counter.
Even if it occurs in the operand field of a statement, dot refers to the address of the first byte of that statement; the value of dot isn't updated until the next machine instruction or assembler directive.